package com.qinhailin.portal.dbm.service;

import com.jfinal.plugin.activerecord.Record;
import com.qinhailin.common.vo.Grid;
import com.qinhailin.portal.dbm.model.DTQuery;

/** 2019-11-23 21:28:46 批量生成 harrydeep@wardyan.top **/
public class DTQueryServiceImpl extends MasterServiceImpl<DTQuery> {

	public DTQueryServiceImpl() {super(DTQuery.dao);}
	
	public Grid page(int pageNumber, int pageSize, Record record) {
		Record rd = new Record();
		rd.set("xName LIKE", record.getStr("xName"));
		rd.set("xPath LIKE", record.getStr("xPath"));
		rd.set("xTableName LIKE", record.getStr("xTableName"));
		rd.set("xType =", record.getInt("xType"));
		rd.set("xText LIKE", record.getStr("xText"));
		rd.set("v.dictionary_code =", "Interval");
		String sql = "SELECT m.*, v.name FROM " + this.getTable() + " AS m INNER JOIN dbo.data_dictionary_value AS v ON v.value=m.xInterval ";
		return queryForList(sql,pageNumber, pageSize, rd, null);
	}

	public String getTableName(Integer rQueryID) {
		DTQuery query = this.findByID(rQueryID);
		return query != null ? query.getXTableName() : "";
	}

}
